package io.itit.ecp.admin.provide.action.controller.miniprogram;


import io.itit.ecp.admin.provide.action.resp.MiniProgramResp;
import io.itit.ecp.admin.server.entity.MiniProgramEntity;
import io.itit.ecp.admin.server.service.IMiniProgramService;
import io.itit.grass.common.provide.action.resp.ResultResp;
import io.itit.grass.common.server.utils.ConvertUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小程序首页管理
 */
@Api(tags = {"小程序首页管理"})
@RestController
@RequestMapping("mini/homePage")
@RequiredArgsConstructor
public class MiniHomePageController {

    private final IMiniProgramService miniProgramService;

    @GetMapping("get")
    @ApiOperation("查询首页数据")
    public ResultResp<MiniProgramResp> get(@RequestParam(defaultValue = "1") String id) {
        MiniProgramEntity miniProgram = miniProgramService.getById(id);
        return ResultResp.success(ConvertUtils.convert(miniProgram, MiniProgramResp.class));
    }
}
